//
// Created by Administrator on 2021/4/11.
//
#include "video_learning.h"


void Video::read_video() {
    cv::namedWindow("video");
    system("color F0"); //更改输出界面颜色
    cv::VideoCapture video("D:\\download\\Download\\Example2.mp4");
    if (video.isOpened()){
        std::cout<<"视频中图像的宽度="<<video.get(cv::CAP_PROP_FRAME_WIDTH)<<std::endl;
        std::cout<<"视频中图像的高度="<<video.get(cv::CAP_PROP_FRAME_HEIGHT)<<std::endl;
        std::cout<<"视频帧率="<<video.get(cv::CAP_PROP_FPS)<<std::endl;
        std::cout<<"视频的总帧数="<<video.get(cv::CAP_PROP_FRAME_COUNT)<<std::endl;
    } else{
        std::cout<<"请确认视频文件名是否正确"<<std::endl;
    }
    while (1)
    {
        cv::Mat frame;
        video>>frame;
        if (frame.empty()){
            break;
        }
        cv::imshow("video", frame);
        cv::waitKey(1000/video.get(cv::CAP_PROP_FPS));
    }
    cv::waitKey();
}